home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / TMENUTST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  3.6 KB  |  122 lines

  1. // tmenutst.cpp: Menu test program
  2.  
  3. #include "wsotxscr.h"
  4. #include "msounit.h"
  5.  
  6. void ExitAction(Wso *, MsgPkt &M)
  7. // Quits the pull-down menu program 
  8. {
  9.   M.RtnCode = ShutDown;
  10. }
  11.  
  12. void NoAction(Wso *, MsgPkt &)
  13. // No action here 
  14. {  
  15.   return;
  16. }
  17.  
  18. void PopupAction(Wso *Src, MsgPkt &M)
  19. // Displays a pop-up menu for the menu entry selected 
  20. {  
  21.   Wso *B;
  22.   char Buff[80];
  23.   ((Meso *)Src)->OnClose(M);    // Close the sub-menu 
  24.   M.Code = M.RtnCode;
  25.   FullScrn->SubMgr->EventStep(M);
  26.   // Create the pop-up window 
  27.   B = new Wso(0x11, WindowStyle, DefColors);
  28.   strcpy(Buff, ((Meso *)Src)->Name);
  29.   strcat(Buff, " Action");
  30.   B->SetSize(B->Panel->TextWidth(Buff), B->Panel->TextHeight(2));
  31.   B->Open(FullScrn, 30, 10);
  32.   B->Panel->HzWrt(0, 0, Buff, 0);
  33.   B->SwitchFocus(M);
  34.   M.RtnCode = Idle; M.Code = Idle;
  35.   do {
  36.     B->SubMgr->EventStep(M);
  37.     M.Code = M.RtnCode;
  38.   } while (M.Code != ShutDown &&
  39.           (!B->Active || M.Code != Close || M.Focus != (Iso *)(B)));
  40.   if (M.Code == Close) {
  41.      B->OnClose(M);
  42.      Mouse.WaitForEvent(MouseUp, M.Mx, M.My);
  43.      M.RtnCode = Idle;
  44.   }
  45.   delete B;
  46. }
  47.  
  48. Pmeso *FileBut;      // The File Button
  49. Dmso *FileMenu;      // The File drop menu 
  50. MesoList *FileMList; // The list of entries for File 
  51. Meso *NewBut;
  52. Meso *OpenBut;
  53. Meso *SaveBut;
  54. Meso *CloseBut;
  55. Meso *VtExitBut;
  56.  
  57. Pmeso *EditBut;      // The Edit button
  58. Dmso *EditMenu;      // The Edit drop menu
  59. MesoList *EditMList; // The list of entries for Edit
  60. Meso* CutBut;
  61. Meso *CopyBut;
  62. Meso *PasteBut;
  63.  
  64. Pmeso *ViewBut;      // The View button
  65. Dmso *ViewMenu;      // The View drop menu
  66. MesoList *ViewMList; // The list of entries for View
  67. Meso *AsciiBut;
  68. Meso *HexBut;
  69.  
  70.  Pmso *Hm;             // The horizontal pull-down menu
  71.  MesoList *HzMenuList; // The list of entries for the pull-down 
  72.                        // menu bar 
  73.  
  74. main()
  75. {
  76.   DefColors = CyanColors;
  77.   Setup(MouseOptional, DefColors);
  78.   // ------------Part 1: Setup the File drop menu---------- 
  79.   FileMList = new MesoList;
  80.   NewBut = new Meso("New", PopupAction);
  81.   FileMList->Append(NewBut);
  82.   OpenBut = new Meso("Open", PopupAction);
  83.   FileMList->Append(OpenBut);
  84.   SaveBut = new Meso("Save", PopupAction);
  85.   FileMList->Append(SaveBut);
  86.   CloseBut = new Meso("Close", PopupAction);
  87.   FileMList->Append(CloseBut);
  88.   VtExitBut = new Meso("Exit", ExitAction);
  89.   FileMList->Append(VtExitBut);
  90.   FileMenu = new Dmso(FileMList, 15, 0x11, WindowStyle, DefColors);
  91.   // ----------Part 2: Setup the Edit drop menu----------
  92.   EditMList = new MesoList;
  93.   CutBut = new Meso("Cut", PopupAction);
  94.   EditMList->Append(CutBut);
  95.   CopyBut = new Meso("Copy", PopupAction);
  96.   EditMList->Append(CopyBut);
  97.   PasteBut = new Meso("Paste", PopupAction);
  98.   EditMList->Append(PasteBut);
  99.   EditMenu = new Dmso(EditMList, 15, 0x11, WindowStyle, DefColors);
  100.   // ----------Part 3: Setup the View drop menu---------
  101.   ViewMList = new MesoList;
  102.   AsciiBut = new Meso("Ascii", PopupAction);
  103.   ViewMList->Append(AsciiBut);
  104.   HexBut = new Meso("Hex", PopupAction);
  105.   ViewMList->Append(HexBut);
  106.   ViewMenu = new Dmso(ViewMList, 15, 0x11, WindowStyle, DefColors);
  107.   // ----------Part 4: Setup the main menu bar----------
  108.   HzMenuList = new MesoList;
  109.   FileBut = new Pmeso("File", FileMenu);
  110.   HzMenuList->Append(FileBut);
  111.   EditBut = new Pmeso("Edit", EditMenu);
  112.   HzMenuList->Append(EditBut);
  113.   ViewBut = new Pmeso("View", ViewMenu);
  114.   HzMenuList->Append(ViewBut);
  115.   Hm = new Pmso(HzMenuList, 80, 25, 3, 0x00, 0x00, CyanColors);
  116.   Hm->Open(FullScrn, 0, 0);
  117.   Hm->Inner->Panel->Clear(177, 4); 
  118.   MainEventLoop();                    // Start the event loop 
  119.   CleanUp();
  120. }
  121.  
  122.